<#
Pre-commit 检查（原生 PowerShell）
用途：在提交前运行基础检查，如模板、文档索引与注入风险。
用法：
  pwsh -File scripts/windows/pre-commit-check.ps1
#>
param()

$WindowsDir = Split-Path -Parent $PSCommandPath

$checks = @(
  'check-templates.ps1',
  'check-doc-sync.ps1',
  'check-injection.ps1'
)

$fail = $false
foreach ($c in $checks) {
  Write-Host "运行检查：$c"
  & (Join-Path $WindowsDir $c)
  if ($LASTEXITCODE -ne 0) { $fail = $true }
}

if ($fail) { Write-Error 'Pre-commit 检查失败'; exit 2 } else { Write-Host 'Pre-commit 检查通过'; exit 0 }
